package com.ruoyi.teach.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.teach.domain.TeachPlanContent;
import com.ruoyi.teach.service.ITeachPlanContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教案内容Controller
 * 
 * @author yepanpan
 * @date 2021-03-15
 */
@Api("教案内容管理")
@RestController
@RequestMapping("/teach/planContent")
public class TeachPlanContentController extends BaseController
{
    @Autowired
    private ITeachPlanContentService teachPlanContentService;

    /**
     * 查询教案内容列表
     */
    @ApiOperation("查询教案内容列表")   
    @GetMapping("/select")
    public TableDataInfo select(TeachPlanContent teachPlanContent)
    {
        List<TeachPlanContent> list = teachPlanContentService.selectTeachPlanContentList(teachPlanContent);
        return getDataTable(list);
    }
    

    /**
     * 查询教案内容列表
     */
    @ApiOperation("查询教案内容列表")   
    @PreAuthorize("@ss.hasPermi('teach:planContent:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeachPlanContent teachPlanContent)
    {
        startPage();
        List<TeachPlanContent> list = teachPlanContentService.selectTeachPlanContentList(teachPlanContent);
        return getDataTable(list);
    }

    /**
     * 导出教案内容列表
     */
    @ApiOperation("导出教案内容列表")    
    @PreAuthorize("@ss.hasPermi('teach:planContent:export')")
    @Log(title = "教案内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TeachPlanContent teachPlanContent)
    {
        List<TeachPlanContent> list = teachPlanContentService.selectTeachPlanContentList(teachPlanContent);
        ExcelUtil<TeachPlanContent> util = new ExcelUtil<TeachPlanContent>(TeachPlanContent.class);
        return util.exportExcel(list, "planContent");
    }

    /**
     * 获取教案内容详细信息
     */
    @ApiOperation("获取教案内容详细信息")
    @ApiImplicitParam(name = "id", value = "教案内容ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('teach:planContent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(teachPlanContentService.selectTeachPlanContentById(id));
    }

    /**
     * 新增教案内容
     */
    @ApiOperation("新增教案内容")
    @PreAuthorize("@ss.hasPermi('teach:planContent:add')")
    @Log(title = "教案内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeachPlanContent teachPlanContent)
    {
        return toAjax(teachPlanContentService.insertTeachPlanContent(teachPlanContent));
    }

    /**
     * 修改教案内容
     */
    @ApiOperation("修改教案内容")  
    @PreAuthorize("@ss.hasPermi('teach:planContent:edit')")
    @Log(title = "教案内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeachPlanContent teachPlanContent)
    {
        return toAjax(teachPlanContentService.updateTeachPlanContent(teachPlanContent));
    }

    /**
     * 删除教案内容
     */
    @ApiOperation("删除教案内容")
    @ApiImplicitParam(name = "id", value = "教案内容ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('teach:planContent:remove')")
    @Log(title = "教案内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teachPlanContentService.deleteTeachPlanContentByIds(ids));
    }
}
